const path = require('path')
const { config } = require('process')

const resolve = dir => path.join(__dirname, dir)

module.exports = {
  productionSourceMap: false,
  devServer: {
    open: true,
    proxy: {
      '/proxy': {
        // target: 'http://47.103.215.221:9800',
        target: 'http://192.168.31.210:8081',
        // target: 'http://192.168.1.109:8080',
        changeOrigin: true,
        pathRewrite: {
          '^/proxy': ''
          //   '^/proxy':'y'
        }
      }
    }
  },
  pages: {
    index: {
      entry: 'examples/main.js',
      template: 'public/index.html',
      filename: 'index.html'
    }
  },
  chainWebpack: config => {
    config.module
      .rule('js')
      .include
      .add(resolve('src'))
      .add(resolve('packages'))
      .end()
      .use('babel')
      .loader('babel-loader')
      .options({
        presets: [
          ['@babel/preset-env', {
            modules: false,
            "targets": {
              "chrome": "58",
              "ie": "11"
            }
          }]
        ]
      }).tap(option => {
        return option
      })
  }
}
